package Game_sharePoint;


import static org.junit.Assert.assertEquals;

import java.io.ByteArrayInputStream;
import java.io.ByteArrayOutputStream;
import java.io.InputStream;
import java.io.PrintStream;
import java.lang.reflect.Method;

import org.junit.After;
import org.junit.Before;
import org.junit.Test;

import FamilyTherapy.Board;
import FamilyTherapy.GCWindow;
import FamilyTherapy.Game;
import FamilyTherapy.Player;

public class testGame_SharePoint_3 {

	@Before
	public void setUp() throws Exception {
	}

	@After
	public void tearDown() throws Exception {
	}

	@Test//Y	
	public void testSharePoint_3() throws Exception {
		// preparation

		Game g = Game.class.newInstance();
		g.setNoOfPlayer(4); 
		
		Player[] p = { new Player("a", 1), new Player("b",2)
						,new Player("c", 3),new Player("d", 4) };
		p[0].deductPoint(3);
		p[1].deductPoint(3);
		p[2].deductPoint(2);
		p[3].addPoint(2);
		
		int currentPlayerNo = 3;
		boolean expected = true;
		System.out.println(p[1].getPoint());
		System.out.println(p[0].getPoint());
		System.out.println(p[2].getPoint());
		System.out.println(p[3].getPoint());
		System.out.println(g.getNoOfPlayer());


		Method sharePointMethod = g.getClass().getDeclaredMethod("sharePoint",
				int.class, Player[].class);

		sharePointMethod.setAccessible(true);
		
		
		//for input
		String data = "Y 0"; 	//data to be input 
		InputStream stdin = System.in; 
		try {  
			
			System.setIn(new ByteArrayInputStream(data.getBytes()));
			sharePointMethod.invoke(g, currentPlayerNo, p); 
			
		} 
		finally {  
			System.setIn(stdin); 	//reset input stream as System.in
		} 
		sharePointMethod.setAccessible(false);		

		//String expected = "Player a, do you share your SE point to other players?"
				//+ newLine;
		System.out.println(p[3].getPoint());
		System.out.println(p[0].getPoint());
		
		//assertEquals(expected, outContent.toString());
		assertEquals(expected,p[0].getPoint()==3);
	}

}
	
	